<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>25动画和转场效果</title>
    <style>
        .fade-enter-active, .fade-leave-active {
            transition: opacity 0.5s ease;
        }
        .fade-enter-from, .fade-leave-to {
            opacity: 0;
        }
    </style>
</head>
<body>
<div id="app">
    <button v-on:click="show = !show">切换(show={{ show }})</button>
    <!--过渡效果元素必须放在transition标签内，过渡动画一共有六种状态-->
    <transition name="fade">
        <p v-if="show">显示/隐藏</p>    
    </transition>
    <p v-if="show">显示/隐藏</p>    
</div>
<script src="../vue.global.3.0.5.js"></script>
<script>
    //1、创建一个Vue应用实例，本身是最顶层的根组件
    const app = Vue.createApp({
        data() {
            return { 
                show: true
            }
        }
    });
    //2、定义一个全局组件
    app.component('button-counter', {
        //数据
        data() {
            return {
                counter: 100
            }
        },
        //模板
        template: `
            计算器: {{counter}}
            <button v-on:click="counter++">counter++</button><br>
        `
    });
    //3、挂载，返回值是代理对象并不是应用实例本身
    const vm = app.mount("#app");
</script>
</body>
</html>